{% extends 'index.html' %}
{% block body %}<br>
<style type='text/css'>
@page {
size: A4 portrait;
margin: 1cm;
}
</style>
{% for dao in pageData["objects"] %}
<table style="width:auto;">
<th style="width:70px;">NUMERO</th>
<th style="width:90px;">DATA</th>
<tr>
<td style="width:70px;text-align:center;font-size:10px;"><strong>{{dao.numero}}</strong></td>
<td style="width:90px;text-align:center;font-size:10px;"><strong>{{utils.dateToString(dao.data_inizio)}}</strong></td>
</tr>
</table>
{% if dao.righeprimanota|length >1 %}
<p><b>DESCRIZIONE: </b> {{dao.note|nonone}}</p>
{% endif %}
<table cellpadding="0" cellspacing="0" border="0">
        <th>DESCRIZIONE</th>
        <th >VALORE</th>
        <th>TIPO</th>
        <th>RIF.</th>
    <th>NOTE</th>

        {% for riga in dao.righeprimanota %}
        <tr >
          <td style="width:80%;font-size:14px;" class="odd-detail">{{riga.denominazione}}</td>
            {% if riga.segno =="entrata" %}
                <td style="color:green;width:80px;text-align:center;font-size:14px;" class="odd-detail">{{utils.mNLC(riga.valore,2)}}</td>
            {% elif riga.segno =="uscita" %}
            <td style="color:red;width:80px;text-align:center;font-size:14px;" class="odd-detail">-{{utils.mNLC(riga.valore,2)}}</td>
            {% endif %}
            {% if riga.tipo =="banca" %}
                <td style="color:blue;width:80px;text-align:center;font-size:14px;" class="odd-detail">{{(riga.tipo)}}</td>
            {% elif riga.tipo =="cassa" %}
            <td style="color:orange;width:80px;text-align:center;font-size:14px;" class="odd-detail">{{riga.tipo}}</td>
            {% endif %}
            <td style="width:10%;font-size:10px;" class="odd-detail">{{riga.banca[0:30]}}</td>
        <td style="width:10%;font-size:10px;" class="odd-detail">{{ riga.note_primanota|nonone }}</td>
        </tr>
        {% endfor %}
                {% if dao.righeprimanota|length==1 %}
<tr> <td span=4>NOTE:{{dao.note|nonone}}</td></tr>
{% endif %}
                </table>
    <hr>
    </tr>{% endfor %}
</table>
<table style="width:300px;">

{% set tot = utils.calcolaTotaliPrimeNote(pageData["objects"]) %}
<tr>
        <td style="width:120px;">TOTALE ENTRATE CASSA</td>
<td style="color:green;width:90px;text-align:right;font-size:12px" > {{utils.mNLC(tot["tot_entrate_cassa"],2)}}</td>
</tr>
<tr>
        <td style="width:120px;">TOTALE USCITE CASSA</td>
        <td style="color:red;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot["tot_uscite_cassa"],2)}}</td>
</tr>
        {% if tot["saldo_cassa"] > 0 %}
<tr>
        <td style="width:120px;"><b>SALDO DI CASSA</b></td>
        <td style="color:green;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot["saldo_cassa"],2)}}</td>
</tr>
        {% else %}
<tr>
        <td style="width:120px;"><b>SALDO DI CASSA</b></td>
        <td style="color:red;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot["saldo_cassa"],2)}}</td>
</tr>
         {% endif %}
        {% for k,v in tot["tot_entrate_per_banche"].iteritems() %}
        <tr>
            <td style="width:120px;">ENTRATE {{ utils.getDenominazioneBanca(k) }}</td>
            {% if v > 0 %}
                <td style="color:green;width:90px;text-align:right;font-size:12px">{{ utils.mNLC(v, 2) }}</td>
            {% else %}
                <td style="color:red;width:90px;text-align:right;font-size:12px">{{ utils.mNLC(v, 2) }}</td>
            {% endif %}
        </tr>
        {% endfor %}

<tr>
        <td style="width:120px;">TOTALE ENTRATE BANCA</td>
        <td style="color:green;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot["tot_entrate_banca"],2)}}</td>
</tr>
        {% for k,v in tot["tot_uscite_per_banche"].iteritems() %}
        <tr>
            <td style="width:120px;">USCITE {{ utils.getDenominazioneBanca(k) }}</td>
            {% if v > 0 %}
                <td style="color:green;width:90px;text-align:right;font-size:12px">{{ utils.mNLC(v, 2) }}</td>
            {% else %}
                <td style="color:red;width:90px;text-align:right;font-size:12px">{{ utils.mNLC(v, 2) }}</td>
            {% endif %}
        </tr>
        {% endfor %}
<tr>
        <td style="width:120px;">TOTALE USCITE BANCA</td>
        <td style="color:red;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot["tot_uscite_banca"],2)}}</td>
</tr>
        {% if tot["saldo_banca"] > 0 %}
<tr>
        <td style="width:120px;"><b>SALDO DI BANCA</b></td>
        <td style="color:green;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot["saldo_banca"],2)}}</td>
</tr>
        {% else %}
<tr>
        <td style="width:120px;"><b>SALDO DI BANCA</b></td>
        <td style="color:red;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot["saldo_banca"],2)}}</td>
</tr>
         {% endif %}

{% if utils.setconf("PrimaNota", "saldi_periodo") %}
{% set tot_init = utils.calcolaSaldoPeriodoPrimaNota() %}

{% if utils.getDataFiltroPrimaNota() != '' %}
        {% if tot_init["saldo_cassa"] > 0 %}
<tr>
        <td style="width:120px;"><b>SALDO DI CASSA DAL 01/01</b></td>
        <td style="color:green;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot_init["saldo_cassa"],2)}}</td>
</tr>
        {% else %}
<tr>
        <td style="width:120px;"><b>SALDO DI CASSA DAL 01/01</b></td>
        <td style="color:red;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot_init["saldo_cassa"],2)}}</td>
</tr>
         {% endif %}
        {% if tot_init["saldo_banca"] > 0 %}
<tr>
        <td style="width:120px;"><b>SALDO DI BANCA DAL 01/01</b></td>
        <td style="color:green;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot_init["saldo_banca"],2)}}</td>
</tr>
        {% else %}
<tr>
        <td style="width:120px;"><b>SALDO DI BANCA DAL 01/01</b></td>
        <td style="color:red;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot_init["saldo_banca"],2)}}</td>
</tr>
         {% endif %}
{% endif %}
{% endif %}
</table>
{% endblock %}
